package com.example.forum_system.dao;

import com.example.forum_system.model.User;
import com.example.forum_system.model.VO.UserVO;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserMapper {

    //1.新增用户
    @Insert("insert into t_user (username, password, nickname, phoneNum, email, gender, avatarUrl, isAdmin, remark, state, deleteState, createTime, updateTime) values (#{username}, #{password},#{nickname}, #{phoneNum}, #{email},#{gender}, #{avatarUrl}, #{isAdmin},#{remark}, #{state}, #{deleteState},#{createTime}, #{updateTime})")
    int insertUser(User row);

    //2.获取用户,根据用户id
    @Select("select * from t_user where id=#{id} and deleteState = 0")
    UserVO selectOneById(@Param("id")Long id);

    //3.获取用户,根据用户名
    @Select(" select * from t_user where username=#{username} and deleteState = 0;")
    UserVO selectOneByUsername(@Param("username")String username);

    //4.修改用户信息
    @Update("update t_user set nickname=#{nickname},avatarUrl=#{avatarUrl},phoneNum=#{phoneNum},email=#{email},password=#{password},remark=#{remark},updateTime=#{updateTime} where id=#{id}")
    int updateUser(User user);

//    int insertSelective(User row);
//
//    int updateByPrimaryKeySelective(User row);
//
//    int updateByPrimaryKey(User row);
}